﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using dbPoll_Application.Models;

namespace dbPoll_Application.ViewModels
{
    public class DetailsViewModel
    {
        public Dictionary<String, String> fieldValues;
        public Poll poll;
        public Dictionary<Participant, Dictionary<String, String>> participants;
        public ParticipantGroup group;

        public DetailsViewModel(int participantID, int pollID)
        {
            this.poll = PollRepository.GetPollByID(pollID);
            Dictionary<Participant, Dictionary<String, String>> groupies = new Dictionary<Participant, Dictionary<String, String>>();
            if (poll.isGroup)
            {
                foreach (Participant participant in ParticipantRepository.GetParticipantsOfGroup(ParticipantRepository.GetGroupByGroupID(participantID), poll))
                    groupies.Add(participant,ParticipantRepository.GetParticipantDetailsByParticipantID(participant.participantID,pollID));
                participants = groupies;
                this.group = ParticipantRepository.GetGroupByGroupID(participantID);
            }
            else this.fieldValues = ParticipantRepository.GetParticipantDetailsByParticipantID(participantID,pollID);
            
            
        }
    }
}